
clear all 

//define folder global here

gl Inputs "$folder\1_Inputs"
gl Intermediate "$folder\2_Intermediate"
gl Outputs "$folder\3_Outputs"

********************************************************************************
********************************************************************************
**# TABLE G.13

** IMPORT NEW YORK
use "${Inputs}\NY_monotonicity_estimates.dta", clear
compress

gen 	id = 1 if instsample=="FEMALE" 		& estsample=="NOTFEMALE"
replace id = 2 if instsample=="NOTFEMALE" 	& estsample=="FEMALE"
replace id = 3 if instsample=="BLACK" 		& estsample=="NOTBLACK"
replace id = 4 if instsample=="NOTBLACK"	& estsample=="BLACK"
replace id = 5 if instsample=="STABILIZED"	& estsample=="NOTSTABILIZED"
replace id = 6 if instsample=="NOTSTABILIZED" & estsample=="STABILIZED"

keep if !mi(id) & courtsample=="BENEFITS LINKED"

gen nyco = string(beta, "%10.3fc") + "***"
gen nyse = "(" + string(se, "%10.3fc") + ")"

keep ny* id 
reshape long ny , i(id) j(item) string

gen estsample = "fem" if id==1
replace estsample = "nfem" if id==2
replace estsample = "bla" if id==3 
replace estsample = "nbla" if id==4 
replace estsample = "sta" if id==5 
replace estsample = "nsta" if id==6

keep ny estsample item 
rename ny value 
gen geo =  "ny"

tempfile nydata
save `nydata'

** IMPORT COOK COUNTY
import delimited "${Inputs}\Cook_split_sample_mono_checks.csv", clear

replace	estsample = "bla" if estsample=="black"
replace estsample = "fem" if estsample=="female"
replace estsample = "joi" if estsample=="joint"
replace estsample = "nbla" if estsample=="notblack"
replace estsample = "nfem" if estsample=="notfemale"
replace estsample = "njoi" if estsample=="notjoint"
replace estsample = "nsma" if estsample=="notsmall_landlord"
replace estsample = "sma" if estsample=="small_landlord"

gen pval = 2 * (1-normal(abs(beta/se)))
assert pval==0

gen valueco = string(beta, "%10.3fc") + "***"
gen valuese = "(" + string(se, "%10.3fc") + ")"

keep estsample valueco valuese
reshape long value, i(estsample) j(item) string 
gen geo = "cc"

append using `nydata'

isid geo estsample item
order geo estsample item, first 

levelsof geo, local(geos)
levelsof estsample, local(samps)
levelsof item, local(ites)

foreach gex in `geos' {
	local id1 = "`gex'"
	
	foreach sax in `samps' {
		local id2 = "`sax'"
		
		foreach itex in `ites' {
			local id3 = "`itex'"
			
			levelsof value if geo=="`gex'" & estsample=="`sax'" & item=="`itex'", ///
			clean local(`id1'_`id2'_`id3')
			
			di "`id1'_`id2'_`id3'"
		}
	}
}
	
 
texdoc init "${Outputs}/Supplementary data_Table_G13.tex", replace force 
tex {\footnotesize \begin{tabular}{l l c c} \hline \toprule ///
	Stringency Sample & First Stage Sample & Cook County & New York \\
tex	& & (1) & (2) \\ 

tex \midrule 

tex Female & Male 		& `cc_fem_co' & `ny_fem_co' \\
tex & 					& `cc_fem_se' & `ny_fem_se' \\

tex Male & Female 		& `cc_nfem_co' & `ny_nfem_co' \\
tex & 					& `cc_nfem_se' & `ny_nfem_se' \\	

tex Black & Not Black 	& `cc_bla_co' & `ny_bla_co' \\
tex & 					& `cc_bla_se' & `ny_bla_se' \\	

tex Not Black & Black 	& `cc_nbla_co' & `ny_nbla_co' \\
tex & 					& `cc_nbla_se' & `ny_nbla_se' \\	

tex Joint Action Case & Single Action Case 	& `cc_joi_co' & `ny_joi_co' \\
tex & 					& `cc_joi_se' & `ny_joi_se' \\	

tex Single Action Case & Joint Action Case 	& `cc_njoi_co' & `ny_njoi_co' \\
tex & 					& `cc_njoi_se' & `ny_njoi_se' \\	

tex Rent Stabilized & Not Rent Stabilized 	& `cc_sta_co' & `ny_sta_co' \\
tex & 					& `cc_sta_se' & `ny_sta_se' \\	

tex Not Rent Stabilized & Rent Stabilized 	& `cc_nsta_co' & `ny_nsta_co' \\
tex & 					& `cc_nsta_se' & `ny_nsta_se' \\	

tex Small Landlord & Not Small Landlord 	& `cc_sma_co' & `ny_sma_co' \\
tex & 					& `cc_sma_se' & `ny_sma_se' \\	

tex Not Small Landlord & Small Landlord 	& `cc_nsma_co' & `ny_nsma_co' \\
tex & 					& `cc_nsma_se' & `ny_nsma_se' \\	


tex \bottomrule \\
tex	\end{tabular} }
texdoc close

